Skip to content

fix(cold-store-reaper): per-file commit boundary in prune_backups (#2550) - #3451

Merged
dezren39 merged 1 commit into
mainfrom
queue/5365-2550-prune-per-file
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5365-2550-prune-per-file

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2550. Queue task 5365 (repo-health-code-pilot, lane D); implementation of triage task 3786's pin.

Change — pkgs/cold-store-reaper/cold_store.py, prune_backups apply path

The commit boundary is now per file: for each prune candidate, run the Drive trash PATCH first, then write that file's transfer_ledger row in its own with conn: transaction and commit before the next candidate (connection closed via finally). Previously one transaction wrapped every PATCH and insert across all dbs, so a mid-run ColdStoreError rolled back every ledger row while the Drive trashes persisted — and since list_backups lists only untrashed files, those rows were permanently unwritable.

Unchanged: dry-run behaviour, retention selection (_retention_plan), the success-path result, and the ColdStoreError type/message for a failed trash.

Tests — tests/test_cold_store.py (+1)

test_prune_apply_mid_run_failure_keeps_completed_rows: wraps cold_store.http_request to return HTTP 500 on the 2nd of 5 prune PATCHes and asserts — ColdStoreError raised; exactly 1 file trashed in Drive AND exactly 1 committed backup-prune ledger row, for the same file; the 4 unattempted candidates still appear in a re-run dry plan; a healthy retry trashes and ledgers the remainder with final refs == all 5 pruned filenames, no duplicates.

Laptop (worktree): python3 -m unittest tests.test_cold_store.TestPruneBackups 5/5; full tests.test_cold_store 89 tests OK (1 skipped).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

)

The apply path ran every Drive trash PATCH inside one SQLite transaction interleaved with transfer_ledger inserts: a mid-run failure rolled back every ledger row while the Drive trashes persisted, and trashed files are invisible to list_backups, so those rows could never be rewritten by a retry. Now each candidate is trashed first, then its ledger row commits in its own transaction before the next candidate; the same ColdStoreError still propagates on a failed trash. Regression test injects HTTP 500 on the 2nd of 5 prune PATCHes and asserts 1 trash + 1 committed row for the same file, the remaining candidates still planned, and a healthy retry completing the set with no duplicates.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 09:29
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a59891a9-add5-41fc-b240-7b021890fa07
Commits

Reviewing files that changed from the base of the PR and between 70c2062 and 55d8cd6.

Files selected for processing: 2
  • pkgs/cold-store-reaper/cold_store.py
  • pkgs/cold-store-reaper/tests/test_cold_store.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T09:30:58.300425Z 55d8cd6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant